
import search from '../pages/Search'
import Home from '../pages/Home'
import register from '../pages/Register'
import login from '../pages/Login'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import Paysuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
import GroupOrder from '@/pages/Center/GroupOrder'
import MyOrder from '@/pages/Center/MyOrder'
import Test from '@/pages/Test'

export default [{
    path: '/',
    redirect: '/home' //重定向到首页
 },{
    path: '/home' ,
    component: Home,
    meta: {
       show: true,
    }
 }, {
    name: 'search',
    path: '/search/:keyword?',
    component: search,
 }, {
    path: '/login',
    component: login
 }, {
    path: '/register',
    component: register,
 },{
    name: 'detail',
    path: '/detail/:goodId?',
    component: Detail,
 },{
   name: 'addCartSuccess',
   path: '/addCartSuccess',
   component: AddCartSuccess,
 }, {
   name: 'shopCart',
   path: '/shopCart/:goodId',
   component: ShopCart,
 },{
   name: 'trade',
   path:'/trade',
   component: Trade,
   beforeEnter: (from, to, next) => {
      if (from.path=='/pay') {
         next();
      }else next(false);
   }
 }, {
   name: 'pay',
   path: '/pay',
   component: Pay,
 }, {
   name: 'paysuccess',
   path: '/paysuccess',
   component: Paysuccess,
   // 路由独享首位
   beforeEnter: (to, from, next) => {
      if (from.path=='/pay') {
         next();
      }else next(false);
   }
 }, {
   name: 'center',
   path: '/center',
   component: Center,
   // 二级路由配置的地方
   children: [{
      name: 'grouporder',
      path:'grouporder',
      component: GroupOrder,
   }, {
      name: 'myorder',
      path:'myorder',
      component: MyOrder,
   }, {
      path: '/center',
      redirect: '/center/myorder',
   }],
 }, {
   path: '/test',
   component: Test,
 }]